<?php
if (!defined('ABSPATH')) include('config.php');
header('Content-Type: text/xml');

$rss = '';
$posts = get_posts();


$rss .= '<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>'.get_option('site_name').'</title>
		<link>'.get_option('site_path').'</link>
		<description>Lastest posts from '.get_option('site_name').'.</description>
		<ttl>4000</ttl>';
if ($posts->total > 0) {
	foreach($posts->items as $post) {
		$rss .= '
		<item>
			<title>'.$post->get_title().'</title>
			<author>'.$post->get_author_object()->display_name(false).' ('.$post->get_author_object()->get_email().')</author>
			<link>'.$post->get_permalink(false).'</link>
			<guid isPermaLink="false">'.$post->get_mini_permalink().'</guid>
			<pubDate>'.$post->get_date('D, d M Y H:i:s T').'</pubDate>
			<description><![CDATA['.$post->get_content().']]></description>
		</item>';
	}
} else {
	$rss .= '
		<item>
			<title>No Post</title>
			<author>'.currentuser()->display_name(false).' ('.currentuser()->get_email().')</author>
			<pubDate>'.get_date('D, d M Y H:i:s T').'</pubDate>
			<description><![CDATA[No posts were found.]]></description>
		</item>
	';
}
$rss .= '
	</channel>
</rss>
';

echo $rss;
?>